package com.my.kq.controller;

import com.my.kq.entity.Attendance;
import com.my.kq.entity.Employee;
import com.my.kq.service.EmployeeService;
import com.my.kq.service.attendanceService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

@WebServlet("/attendanceList")
//考勤
public class attendanceList extends HttpServlet {
    private attendanceService attendanceService=new attendanceService();
    private com.my.kq.service.EmployeeService EmployeeService=new EmployeeService();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {

           req.setCharacterEncoding("utf-8");
            resp.setCharacterEncoding("utf-8");
            resp.setContentType("text/html;charset=utf-8");
            HttpSession session = req.getSession();
            Employee cook =(Employee) session.getAttribute("cook");
            Integer id = cook.getId();
            Employee yee= EmployeeService.Empcx(id);
            Integer number = yee.getEmployee_number();

            List<Attendance> list=  attendanceService.attList(number);
            session.setAttribute("aList",list);
            req.getRequestDispatcher("jsp/admin/oneself_attendance.jsp").forward(req,resp);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
